package com.shijie.sjoj.model.base;

import lombok.extern.slf4j.Slf4j;

/**
 * 基础异常类
 * <pre>
 * 可覆盖两个静态方法：将返回值设置为自己
 * public static InheritException throwError(String message);
 * public static InheritException throwError();
 * </pre>
 *
 * @author ZSJ
 */
@Slf4j
public class BaseException extends RuntimeException {

    /**
     * 默认的异常信息
     */
    protected static final String EXCEPTION_DEFAULT_MESSAGE = "发生异常";

    protected BaseException(String message) {
        super(message);
    }

    /**
     * 抛出基础异常
     *
     * @param message String 错误信息
     * @return BaseException
     */
    public static BaseException throwError(String message) {
        return new BaseException(null != message ? message : EXCEPTION_DEFAULT_MESSAGE);
    }

    /**
     * 抛出基础异常
     *
     * @return BaseException
     */
    public static BaseException throwError() {
        return new BaseException(EXCEPTION_DEFAULT_MESSAGE);
    }


}
